package af.fx.base.lesson5;

import javafx.application.Application;
import javafx.application.Platform;
import javafx.stage.Stage;

/**
 * @Description
 * @Author AF
 * @Version 1.0.0
 * @Date 2024/1/24
 */
public class Main extends Application {

    public static void main(String[] args) {
        Application.launch(Main.class, args);
    }

    @Override
    public void start(Stage primaryStage) throws Exception {
        System.out.println("start方法里面的线程名字=" + Thread.currentThread().getName());

        Platform.runLater(new Runnable() {
            @Override
            public void run() {
                // 这个也是JavaFX Application Thread，和start线程是一样的，所以它只是个队列,只能做轻量的操作，不然会堵塞Application Thread
                System.out.println("run方法里面的线程名字=" + Thread.currentThread().getName());

                int i = 1;

                while (i <= 10) {
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }
                    System.out.println("i = " + i);
                    i++;
                }
            }
        });

        // primaryStage.show();
    }
}
